//
//  CYNetworkCollectRecord.m
//  CreditAddressBook
//
//  Created by LE on 15/12/30.
//  Copyright © 2015年 Lee. All rights reserved.
//

#import "CYNetworkCollectRecord.h"
#import "MJExtension.h"
#import "UIImageView+WebCache.h"
#import "CYURL.h"

@implementation CYNetworkCollectRecord

+ (NSDictionary *)replacedKeyFromPropertyName {
    return @{@"recordId": @"id"};
}

/**
 *  图片展示view
 */
- (UIView *)picAddressListView {
    if (self.picAddressList && self.picAddressList.count) {
//        CGFloat imageW = CYScreeSize.width;
        CGFloat imageH = 200;
        UIView *view = [[UIView alloc] initForAutoLayout];
        NSMutableArray *images = [NSMutableArray array];
//        view.width = viewW;
        for (int i = 0; i < self.picAddressList.count; i++) {
            NSString *path = self.picAddressList[i];
            UIImageView *imageView = [[UIImageView alloc] initForAutoLayout];
//            imageView.width = viewW;
//            imageView.contentMode = UIViewContentModeScaleAspectFill;
            imageView.contentMode = UIViewContentModeScaleAspectFit;
            [imageView sd_setImageWithURL:CYURLWithService(path) placeholderImage:[UIImage imageNamed:@"putao_icon_quick_replace_s"]];
            [view addSubview:imageView];
            [imageView autoSetDimension:ALDimensionHeight toSize:imageH];
            if (i == 0) {
                [imageView autoPinEdgesToSuperviewEdgesWithInsets:UIEdgeInsetsZero excludingEdge:ALEdgeBottom];
            } else if (i == self.picAddressList.count - 1) {
                [imageView autoPinEdgesToSuperviewEdgesWithInsets:UIEdgeInsetsZero excludingEdge:ALEdgeTop];
                [imageView autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:images.lastObject withOffset:8];
            } else {
                [imageView autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:images.lastObject withOffset:8];
                [imageView autoPinEdge:ALEdgeLeft toEdge:ALEdgeLeft ofView:view];
                [imageView autoPinEdge:ALEdgeRight toEdge:ALEdgeRight ofView:view];
            }
            [images addObject:imageView];
        }
        return view;
    }
    return nil;
}
@end
